﻿using FMusicReload.NetMusicNetwork;
using FMusicReload.Utils;
using Newtonsoft.Json.Linq;
using System;
using System.IO;

namespace FMusicReload.Views
{
    public partial class LyricPage
    {
        public LyricPage()
        {
            InitializeComponent();

            var c = new MusicLyric(MainWindow.MusicDetil.ToString());

            var engine = new lyricEngine(c.Lyric, c.Translate);
            LryicListView.ItemsSource = engine.GetLyricList();
            engine.RunTimeServer();
            LryicListView.SelectedIndex = engine.LrcIndex;

            engine.LrcNext += (index) =>
                 LryicListView.Dispatcher.Invoke(() =>
                 {
                     LryicListView.SelectedIndex = index;
                     LryicListView.ScrollIntoView(LryicListView.SelectedItem);
                     
                 });

            GC.Collect();
        }
    }
}
